//package org.hxyjs.service.impl;
//
//import org.hxyjs.dao.ExpertActivityRecordDao;
//import org.hxyjs.dto.DTO;
//import org.hxyjs.dto.MessageEnum;
//import org.hxyjs.entity.ExpertActivityRecord;
//import org.hxyjs.page.PageInfo;
//import org.hxyjs.service.ExpertActivityRecordService;
//import org.hxyjs.vo.ExpertActivityRecordView;
//import org.springframework.cache.annotation.Cacheable;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.text.SimpleDateFormat;
//import java.util.List;
//import java.util.Optional;
//
//@Service("expertActivityRecordService")
//public class ExpertActivityRecordServiceImpl implements ExpertActivityRecordService {
//    @Resource
//    ExpertActivityRecordDao expertActivityRecordDao;
//
//    //查询全部
//    @Override
//    public DTO<ExpertActivityRecord> getAllExpertActivityRecords()  throws Exception{
//        List<ExpertActivityRecord> expertActivityRecords = expertActivityRecordDao.getAllExpertActivityRecords();
//        //isPresent表示判断不为空成立则dto为？与：之间的对象
//        MessageEnum messageEnum  = Optional.ofNullable(expertActivityRecords).isPresent()?MessageEnum.GETEXPERTACTIVITYRECORDALLSUCCESS:MessageEnum.GETEXPERTACTIVITYRECORDALLFAIL;
//        return new DTO<ExpertActivityRecord>(messageEnum.getCode(),messageEnum.getMessage(),expertActivityRecords);
//    }
//
//    //删除
//    @Override
//    public DTO<ExpertActivityRecord> deleteExpertActivityRecordByExarno(String exarno)  throws Exception{
//        Integer result = expertActivityRecordDao.deleteExpertActivityRecordByExarno(exarno);
//        //isPresent表示判断不为空成立则dto为？与：之间的对象
//        MessageEnum messageEnum  =result> 0?MessageEnum.DELETEEXPERTACTIVITYRECORDSUCCESS:MessageEnum.DELETEEXPERTACTIVITYRECORDFAIL;
//        return new DTO<ExpertActivityRecord>(messageEnum.getCode(),messageEnum.getMessage());
//    }
//
//    //按主键查询
//    @Override
//    public DTO<ExpertActivityRecord> getExpertActivityRecordByExarno(String exarno)  throws Exception{
//        ExpertActivityRecord expertActivityRecords = expertActivityRecordDao.getExpertActivityRecordByExarno(exarno);
//        //isPresent表示判断不为空成立则dto为？与：之间的对象
//        MessageEnum messageEnum  = Optional.ofNullable(expertActivityRecords).isPresent()?MessageEnum.GETEXPERTACTIVITYRECORDSUCCESS:MessageEnum.GETEXPERTACTIVITYRECORDFAIL;
//        return new DTO<ExpertActivityRecord>(messageEnum.getCode(),messageEnum.getMessage(),expertActivityRecords);
//    }
//
//    //修改
//    @Override
//    public DTO<ExpertActivityRecord> updateExpertActivityRecordByExarno(ExpertActivityRecordView expertActivityRecordView) throws Exception {
//        ExpertActivityRecord expertActivityRecord = dateFormat(expertActivityRecordView);
//        Integer result = expertActivityRecordDao.updateExpertActivityRecordByExarno(expertActivityRecord);
//        //isPresent表示判断不为空成立则dto为？与：之间的对象
//        MessageEnum messageEnum  =result> 0?MessageEnum.UPDATEEXPERTACTIVITYRECORDSUCCESS:MessageEnum.UPDATEEXPERTACTIVITYRECORDFAIL;
//        return new DTO<ExpertActivityRecord>(messageEnum.getCode(),messageEnum.getMessage());
//    }
//
//    //增加
//    @Override
//    public DTO<ExpertActivityRecord> addExpertActivityRecord(ExpertActivityRecord expertActivityRecord) throws Exception {
//        Integer result = expertActivityRecordDao.addExpertActivityRecord(expertActivityRecord);
//        //isPresent表示判断不为空成立则dto为？与：之间的对象
//        MessageEnum messageEnum  =result> 0?MessageEnum.ADDEXPERTACTIVITYRECORDSUCCESS:MessageEnum.ADDEXPERTACTIVITYRECORDFAIL;
//        return new DTO<ExpertActivityRecord>(messageEnum.getCode(),messageEnum.getMessage());
//    }
//
//    /**
//     * 学生选课成功 学生成绩加1分，从选课信息中可以获得学生的学号就能查询出学生原来的成绩
//     * @param
//     * @return
//     * @throws Exception
//     */
//    @Cacheable(value = "myCache",key = "#cacheId")
//    @Override
//    public DTO<ExpertActivityRecord> getExpertActivityRecordByPage(PageInfo pageInfo ,String cacheId) throws Exception {
//        List<ExpertActivityRecord> expertActivityRecords = expertActivityRecordDao.getExpertActivityRecordByPage(pageInfo);
//        //isPresent表示判断不为空成立则dto为？与：之间的对象
//        MessageEnum messageEnum  = Optional.ofNullable(expertActivityRecords).isPresent()?MessageEnum.GETEXPERTACTIVITYRECORDSUCCESS:MessageEnum.GETEXPERTACTIVITYRECORDFAIL;
//        return new DTO<ExpertActivityRecord>(messageEnum.getCode(),messageEnum.getMessage(),expertActivityRecords,pageInfo);
//    }
//
//    public DTO<ExpertActivityRecord> getExpertActivityRecordByPage(PageInfo pageInfo) throws Exception {
//        List<ExpertActivityRecord> expertActivityRecords = expertActivityRecordDao.getExpertActivityRecordByPage(pageInfo);
//        //isPresent表示判断不为空成立则dto为？与：之间的对象
//        MessageEnum messageEnum  = Optional.ofNullable(expertActivityRecords).isPresent()?MessageEnum.GETEXPERTACTIVITYRECORDSUCCESS:MessageEnum.GETEXPERTACTIVITYRECORDFAIL;
//        return new DTO<ExpertActivityRecord>(messageEnum.getCode(),messageEnum.getMessage(),expertActivityRecords,pageInfo);
//    }
//    public ExpertActivityRecord dateFormat(ExpertActivityRecordView expertActivityRecordView) throws Exception{
//        ExpertActivityRecord expertActivityRecord = new ExpertActivityRecord();
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        expertActivityRecord.setExardate(sdf.parse(expertActivityRecordView.getExardate()));
//        expertActivityRecord.setEdno(expertActivityRecordView.getEdno());
//        expertActivityRecord.setEno(expertActivityRecordView.getEno());
//        expertActivityRecord.setExarno(expertActivityRecordView.getExarno());
//
//        return expertActivityRecord;
//
//
//    }
//
//}
